package com.aki.ai_property.service.impl;

/**
 * Author:WuChuangChuang
 * Date:2022/9/1 23:24
 */

import com.aki.ai_property.dao.RentingDtoDao;
import com.aki.ai_property.dto.RentingDto;
import com.aki.ai_property.service.intf.RentingDtoService;
import com.aki.ai_property.util.StringUtil;
import com.aki.ai_property.vo.PageBean;
import com.aki.ai_property.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  四表联查 */
@Service
public class RentingDtoServiceImpl implements RentingDtoService {
    @Autowired
    private RentingDtoDao dao;


    /** 新增 */
    @Override
    public Result save(RentingDto rentingDto) {
        if(dao.save(rentingDto) >0){
            return Result.ok("新增成功");
        }
        return Result.fail("新增失败");
    }


    /** 查询 */
    @Override
    public PageBean all(String houseType, int page, int limit) {
        System.out.println(dao.all(houseType, page, limit));
        if (StringUtil.isNotEmpty(houseType)){
            houseType = "%"+houseType+"%";
        }
        int start = (page-1)*limit;
        return PageBean.ok(dao.selectCount(houseType), dao.all(houseType, start, limit) );
    }
}
